package com.yequan.springdemo.ioc.annotation.po;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;


/**
 * @author yequan
 * @date 2021/10/20 16:44
 **/
@Component
public class Man extends Human implements BeanPostProcessor {

    @Autowired
    private Apple apple;

    public void work(){
        System.out.println("工作");
    }

    public void injectFood() {
        super.setFood(apple);
    }

    @PostConstruct
    public void te(){
        System.out.println(apple.getColor());
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return null;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        injectFood();
        return bean;
    }

}
